<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/business/trail.js"></script>

<script type="text/javascript">
    // 	<s:iterator value="containers" status="st">
    // 		<s:if test="#st.first">containers=[</s:if>
    // 		{id:"<s:property value='id'/>",
    // 			size:"<s:property value='ct_size'/>",
    // 			type:"<s:property value='ct_type'/>",
    // 			index:"<s:property value='#st.index+1'/>" }
    // 		<s:if test="#st.last">]
    // 		</s:if><s:else>,</s:else>
    // 	</s:iterator>
    // 	var trai_tds=$("#tril_goodsList tr:gt(0)").find("td:eq(7)");
    // 	$.each(trai_tds,function(i,n){
    // 		var idsStr=$(n).text();
    // 		var str="";
    // 		if(idsStr){
    // 			var ids=idsStr.split(",");
    // 			$.each(ids,function(k,p){
    // 				$.each(containers,function(j,m){
    // 					if(m.id==p){
    // 						str+=m.index+"号柜-"+m.size+"'"+m.type;
    // 						if(k!=ids.length-1){
    // 							str+=",";
    // 						}
    // 					}
    // 				});
    // 			});
    // 		}
    // // 		$(n).text(str);
    // 	});
    // 	initCtNumTypeDropdown(containers);
    $(document).ready(function () {
        containers = Gd_ctNumTypeMsg();
        initCtNumTypeDropdown(containers);
        countTotalSizeType();
    });
</script>
<style>
    #containers .li1 input {
        width: 30px;
    }
</style>
<div class="page_font">
    <div>
        <input value="${trial.id }" type="hidden" name="trial.id"/>
        <ul class="ul1">
            <li class="li1 first_li">拖车业务代理人：</li>
            <li class="li1"><input type="text" id="trial_sup_id"
                                   name="trial.supCompany.name" value="${trial.supCompany.name }"/><input
                    type="hidden" id="trial_sup" name="trial.supCompany.id"
                    value="${trial.supCompany.id }"/></li>
        </ul>
    </div>
    <table>
        <tr>
            <td class="first_li">柜量信息：</td>
        </tr>
    </table>
    <div id="trail">
        <ul id="containers">
            <li class="li1">
                <span class='containerType'><input type="text" id="ct_num" class="ct_num"/><input type="text"
                                                                                                  id="ct_size"
                                                                                                  class="ct_size"/><input
                        type="text" id="ct_type" class="ct_type"/></span>
            </li>
            <li><input type="button" onclick="addCtTrailType();" value="添加柜型"/><input type="button"
                                                                                      onclick="delCtTrailType();"
                                                                                      id="deleteType" value="删除柜型">
                <input type="button" onclick="showTrailInfo();" value="确认柜量"/></li>
        </ul>
    </div>
    <div id="trial_info_show"
         <s:if test="trial==null||trial.id==null||trial.id==''">style="display: none;"</s:if>>
        <table>
            <tr>
                <td class="first_li">装运信息：</td>
            </tr>
        </table>
        <table rules="rows" id="trial_gd_input" class="baseInfoTB_bg" style="margin:10px 35px">
            <input type="hidden" value="" id="gd_id">
            <tr>
                <td class="labelTD fill_cell">货物名称：</td>
                <td><input type="text" id="gd_name" name="gd_name" class="textInput validate[required]"/></td>
                <td class="labelTD fill_cell">装柜工厂名称：</td>
                <td><input type="text" id="gd_contacter_company" class="textInput validate[required]"/></td>
                <td class="labelTD fill_cell">工厂地址：</td>
                <td><input type="text" id="gd_contacter_address" class="textInput validate[required]"/></td>
            </tr>
            <tr>
                <td class="labelTD fill_cell">联系人：</td>
                <td>
                    <input type="text" id="gd_contacter_name" class="textInput validate[required]"/>
                    <input type="hidden" id="gd_contacter_id"/>
                </td>
                <td class="labelTD fill_cell">联系电话：</td>
                <td><input class="textInput" type="text" id="gd_contacter_phone"/></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td class="labelTD fill_cell">请选择柜型：</td>
                <td colspan="3"><input id="gd_ctNumType" type="text" readonly="readonly"
                                       class="ui-state-default ui-corner-all validate[required]"
                                       style="width: 300px"/><span>&nbsp;&nbsp;全选:<input type="checkbox"
                                                                                         onclick="selectAll();"/></span>
                </td>
                <td></td>
                <td></td>
                <!-- 		        <td colspan="2" ><font color="red">1-20'GP:1为柜号，20'GP为柜型号。如果1-20'GP有多条记录，即1-20'GP在多个工厂地址装货</font></td> -->
                <!-- 		        <td></td> -->
                <!-- 		        <td></td> -->
            </tr>
            <tr>
                <td class="labelTD fill_cell">建议装柜时间：</td>
                <td><input type="text" id="gd_zhDate" class="textInput validate[required]"/>
                    <input type="text" id="gd_zhTime" class="textInput validate[required]" maxlength="2" size="2"/><font
                            color="red">:00</font>
                </td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
            </tr>
            <tr>
                <td class="labelTD fill_cell ">备注：</td>
                <td colspan="4"><input class="textInput" type="text" id="gd_remark" style="width: 430px"/></td>
                <td colspan="1"><input type="button" value="确认货物" style="text-align: right;"
                                       onclick="confirmgoodesad();"/></td>
            </tr>
        </table>
        <table>
            <tr>
                <td class="first_li">货物列表：</td>
                <td>柜总计&nbsp;&nbsp;</td>
                <td><span id="totalSizeType"></span></td>
            </tr>
        </table>
        <table class="dataTB dataTB_Individual trail_dataTB_Individual" id="tril_goodsList" border="1">
            <tr class="trhead">
                <td class="titleTD trail_titleTD" lang="name">货物名称</td>
                <td class="titleTD trail_titleTD" lang="contacter_company">装柜工厂名称</td>
                <td class="titleTD trail_titleTD" lang="id" style="display: none;">装柜工厂id</td>
                <td class="titleTD trail_titleTD" lang="contacter_address">工厂地址</td>
                <td class="titleTD trail_titleTD" lang="contacter_name">联系人</td>
                <td class="titleTD trail_titleTD" lang="contacter_id" style="display: none;">联系人id</td>
                <td class="titleTD trail_titleTD" lang="contacter_phone">联系电话</td>
                <td class="titleTD trail_titleTD" lang="ctNumType">柜型</td>
                <td class="titleTD trail_titleTD" lang="zhDate" style="width: 150px;">建议装柜时间</td>
                <td class="titleTD trail_titleTD" lang="remark">备注</td>
                <td class="titleTD trail_titleTD">操作</td>
                <td class="" style="display: none;">柜id</td>
            </tr>
            <s:iterator value="trial.gdes">
                <tr onclick="editgoodesad(this);">
                    <td><s:property value="name"/></td>
                    <td><s:property value="contacter.company"/></td>
                    <td style="display: none;"><s:property value="id"/></td>
                    <td><s:property value="contacter.address"/></td>
                    <td><s:property value="contacter.name"/></td>
                    <td style="display: none;"><s:property value="contacter.id"/></td>
                    <td><s:property value="contacter.phone"/></td>
                        <%-- <td><s:iterator value="containers" status="c"><s:property value="id"/>-<s:property value="ct_size" />'<s:property value="ct_type"/><s:if test="!#c.last">,</s:if></s:iterator></td>--%>
                        <%-- 				<td><s:iterator value="containers" status="c"><s:property value="id"/><s:if test="!#c.last">,</s:if></s:iterator></td> --%>
                    <td><s:property value="ctNumType"/></td>
                    <td><s:date name="zhDate" format="yyyy-MM-dd HH:mm"/></td>
                    <td><s:property value="remark"/></td>
                    <td style='width:200px;'><a onclick='copygoodes(this)'
                                                style='cursor: pointer;color: blue;margin: 10px;'>复制</a>||<a
                            onclick='delgoodes(this)' style='cursor: pointer;color: red;margin: 10px;'>删除</a></td>
                    <td style="display: none;"></td>

                </tr>
            </s:iterator>
        </table>
        <div id="new_tril_goodsList"></div>
        <div id="so">
            <table>
                <tr>
                    <td class="first_li">SO信息：</td>
                </tr>
                <tr>
                    <td><s:if test="trial.soDoc!=null"><s:property value="trial.soDoc.name"/><input type="button"
                                                                                                    value="删除附件"
                                                                                                    onclick="cancleUpload();"/></s:if><s:else>上传</s:else>
                    </td>
                    <td><input id="button_so" type="button" value="选择文件" onclick="upload();"/></td>
                </tr>
                <tr>
                    <td>SO号：</td>
                    <td><input type="text" class="textInput" id="so_num" name="trial.so" value="${trial.so }"/></td>
                </tr>
            </table>
        </div>
        <div id="upload_so" style="display:none;">
            SO信息：<span id="soValue"></span><input name="trial.soDoc.id" value="<s:property value="trial.soDoc.id" />"
                                                  id="soid" style="display:none;"/>
        </div>
        <div id="dialog001" style="display:none">
            <s:form id="uploadForm" action="attach-upload" enctype="multipart/form-data" method="POST">
                <s:file label="选择文件" name="attach"></s:file>
                <s:submit value="上传"></s:submit>
            </s:form>
        </div>
    </div>
</div>
